package com.spring.boot.email.dto;

import lombok.Data;

import java.io.Serializable;

@Data
public class BaseResult<T> implements Serializable {
    public static final int STAUTS_SUCCESS = 200;
    public static final int STAUTS_FAIL = 500;

    private int status;
    private String message;
    private T data;

    public static <T>BaseResult success() {
        return BaseResult.creatResult(STAUTS_SUCCESS, "成功", null);
    }

    public static <T>BaseResult success(T data) {
        return BaseResult.creatResult(STAUTS_SUCCESS, "成功", data);
    }

    public static <T>BaseResult fail() {
        return BaseResult.creatResult(STAUTS_FAIL, "失败", null);
    }

    public static <T>BaseResult fail(String message) {
        return BaseResult.creatResult(STAUTS_FAIL, message, null);
    }

    public static <T>BaseResult fail(int status, String message) {
        return BaseResult.creatResult(STAUTS_FAIL, message, null);
    }


    private static <T>BaseResult<T> creatResult(int stauts, String message, T data) {
        BaseResult baseResult = new BaseResult();
        baseResult.setStatus(stauts);
        baseResult.setMessage(message);
        baseResult.setData(data);
        return baseResult;
    }


}
